﻿using BlockeyEssentials;
using BlockeyEssentials.Drawing;
using BlockeyEssentials.ScreenSystem;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using BlockeyEssentials.ScreenSystem.ScreenTypes;
using BlockeyEssentials.Input;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.GamerServices;

namespace Blockey.MenuSystemScreens
{
    public class PressStartScreen : Screen
    {
        public PressStartScreen(ScreenManager oManager)
            : base(oManager)
        {
            var oGame = oManager.Game;
            var oShape = oGame.GraphicsDevice.Viewport.Bounds;

            _Image = new SpriteR(All.Texture_Square, oShape);
            _Image.Color = Color.Green;
            _Image.Layer = 1;
        }

        #region Methods

        public override void Update()
        {
            if (Active)
            {
                var oStart = false;

                var oKeyboardInput = InputManager.Keyboard;
                if (oKeyboardInput.JustPressed(Keys.Enter, Keys.F))
                    oStart = true;

                var oGamePadInput = InputManager.GamePad1;
                if (oGamePadInput.JustPressed(Buttons.A))
                    oStart = true;

                if (oStart)
                {
                    if (Gamer.SignedInGamers.Count == 0)
                        SignIn();

                    if (Gamer.SignedInGamers.Count > 0)
                        Remove();
                }
            }
        }

        public void SignIn()
        {
            if (Guide.IsVisible == false)
            {
                Guide.ShowSignIn(1, true);
            }
        }

        public void SetUpStorage()
        {

        }

        public override void Draw(SpriteBatch oSB)
        {
            _Image.Draw(oSB, Transition);
        }

        public override void ActionWhenFullyRemoved()
        {
            var oScreen = new MainMenuScreen(_Manager);
            _Manager.AddScreen(oScreen);
        }

        #endregion

        private SpriteR _Image;
    }
}
